<?php
namespace common\models\shop;

use common\models\Common;
use common\models\user\User;
use yii\db\ActiveRecord;

class Goods extends Common
{
    public static function tableName()
    {
        return '{{%goods_info}}';
    }

    //用户
    public function getUser() {
        return $this->hasOne(User::className(), ['id' => 'user_id']);
    }

    //用户
    public function getCategory() {
        return $this->hasOne(GoodsCategory::className(), ['id' => 'category_id']);
    }

    // 通过名字获取ID  模糊匹配
    public static function searchByType($type = '') {
        $where['type'] = $type;
        $list = static::getByWhere($where, ['id']);
        return array_column($list, "id");
    }

}